package com.tkjt.pms.modules.kpiAudit.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tkjt.pms.common.entity.TkIndexValueAudit;
import com.tkjt.pms.common.utils.EsDateUtils;
import com.tkjt.pms.common.utils.EsJsonUtils;
import com.tkjt.pms.common.utils.EsStringUtils;
import com.tkjt.pms.common.vos.RequestJson;
import com.tkjt.pms.modules.common.mapper.TkIndexValueAuditMapper;
import com.tkjt.pms.modules.common.service.TkDataConfigService;
import com.tkjt.pms.modules.kpiAudit.model.AuditRecordsResponseModel;
import com.tkjt.pms.modules.kpiAudit.service.KpiAuditBizService;
import com.tkjt.pms.modules.kpiAudit.service.TkAuditBizService;
import com.tkjt.pms.modules.kpiAudit.service.TkAuditService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class TkAuditServiceImpl implements TkAuditService {
	@Autowired
	private TkDataConfigService tkDataConfigService;

	@Autowired
	private Map<String, TkAuditBizService> tkAuditBizServiceMap = new HashMap<>();
	@Override
	public Result getAuditList(LoginUser loginUser, HttpServletRequest httpServletRequest, String requestType) {
		String dataType = tkDataConfigService.getDataType(loginUser.getUsername());
		TkAuditBizService tkAuditBizService = checkService(dataType);
		return tkAuditBizService.getAuditList(httpServletRequest,requestType,dataType);
	}

	public TkAuditBizService checkService(String dataType) {
		String serviceName = "tkAuditBizService" + EsStringUtils.onlyFirstCharUpper(dataType);
		return tkAuditBizServiceMap.get(serviceName);
	}
}
